#include "Parent.h"
#include <iostream>
#include <vector>

using namespace std;

typedef int INTEGER;
typedef int INDEX;
typedef string STRING;
typedef int LINENUM;

	Parent::Parent(){
		_size = 0;
		_table = vector<pair<LINENUM,LINENUM>>();
	}
	BOOLEAN Parent::setParentPair(LINENUM line1, LINENUM line2){
		pair<LINENUM,LINENUM> p = pair<LINENUM,LINENUM>(line1,line2);
		_table.push_back(p);
		_size++;
		return true;
	}
	vector <pair <LINENUM, LINENUM>> Parent::getParentPair(){
		return _table;
	}
	INTEGER Parent::getParentSize(){
		return _size;
	}
	LINENUM Parent::getMyParent(LINENUM line2){
		for(int i=0;i<_size;i++){
			if(_table.at(i).second==line2){
				return _table.at(i).first;
			}
		}
		return -1;
	}
	vector<LINENUM> Parent::getMyChildren(LINENUM line1){
		vector<LINENUM> result =vector<LINENUM>();
		for(int i=0;i<_size;i++){
		if(_table.at(i).first==line1){
			result.push_back(_table.at(i).second);
			}
		}
		return result;
	}
	BOOLEAN Parent::isParent(LINENUM line1, LINENUM line2){
		LINENUM tempLine = getMyParent(line2);
		return tempLine == line1;
	}
	BOOLEAN Parent::isParentStar(LINENUM line1, LINENUM line2){
		if(isParent(line1,line2))
			return true;
		else if(getMyParent(line2) == -1)
			return false;
		else 
			return isParentStar(line1, getMyParent(line2));
	}